home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / progem.lzh / apndx13.prf < prev    next >
Text File  |  1987-06-23  |  26KB  |  1,193 lines

  1. .!****************************************************************************
  2. .! 
  3. .! ANTIC PUBLISHING INC., COPYRIGHT 1985.  REPRINTED BY PERMISSION.
  4. .!
  5. .! ** Professional GEM ** by Tim Oren
  6. .!
  7. .! Proff File by ST enthusiasts at
  8. .! Case Western Reserve University
  9. .! Cleveland, Ohio
  10. .! uucp : decvax!cwruecmp!bammi
  11. .! csnet: bammi@case
  12. .! arpa : bammi%case@csnet-relay
  13. .! compuserve: 71515,155
  14. .!
  15. .!****************************************************************************
  16. .!
  17. .!            Begin Appendix XIII
  18. .!
  19. .!***************************************************************************
  20. .!
  21. .!
  22. .AP XIII Sample Code for Part XVII
  23.             /*** rsconv.h ***/
  24. #define MODE 0      /* TREE */
  25. #define N2F 7      /* OBJECT in TREE #0 */
  26. #define F2N 8      /* OBJECT in TREE #0 */
  27. #define DEF2 15      /* OBJECT in TREE #0 */
  28. #define HELPMODE 21      /* OBJECT in TREE #0 */
  29. #define CONVMODE 22      /* OBJECT in TREE #0 */
  30. #define QUITMODE 23      /* OBJECT in TREE #0 */
  31. #define NODEF 0      /* STRING */
  32. #define DEFYES 18      /* OBJECT in TREE #0 */
  33. #define DEFNO 19      /* OBJECT in TREE #0 */
  34. #define HELP 1      /* TREE */
  35. #define NOMEM 1      /* STRING */
  36. #define DFNYES 20      /* OBJECT in TREE #0 */
  37. #define DEF1 13      /* OBJECT in TREE #0 */
  38. #define RSC1 10      /* OBJECT in TREE #0 */
  39. #define RSC2 12      /* OBJECT in TREE #0 */
  40. #define PROGRESS 2      /* TREE */
  41. #define STRINGS 3      /* TREE */
  42. #define PLINE 2      /* OBJECT in TREE #2 */
  43. #define IMGALIGN 2      /* OBJECT in TREE #3 */
  44. #define RSCREAD 1      /* OBJECT in TREE #3 */
  45. #define BYTESWAP 3      /* OBJECT in TREE #3 */
  46. #define RSCWRITE 4      /* OBJECT in TREE #3 */
  47. #define DEFREAD 5      /* OBJECT in TREE #3 */
  48. #define DEFWRITE 6      /* OBJECT in TREE #3 */
  49. .bp
  50.             /*** rscvmain.c **/
  51. /*------------------------------*/
  52. /*    includes        */
  53. /*------------------------------*/
  54.  
  55. #include "portab.h"                /* portable coding conv    */
  56. #include "machine.h"                /* machine depndnt conv    */
  57. #include "obdefs.h"                /* object definitions    */
  58. #include "gembind.h"                /* gem binding structs    */
  59. #include "osbind.h"                /* BDOS definitions    */
  60. #include "gemdefs.h"
  61. #include "rsconv.h"
  62.  
  63.  
  64. /*------------------------------*/
  65. /*    defines            */
  66. /*------------------------------*/
  67.  
  68. #define    NIL        -1
  69. #define DESK        0
  70. #define    ARROW        0
  71. #define    HOUR_GLASS    2            
  72. #define END_UPDATE    0
  73. #define    BEG_UPDATE    1
  74.  
  75. typedef struct memform
  76.     {
  77.     WORD        *mp;
  78.     WORD        fwp;
  79.     WORD        fh;
  80.     WORD        fww;
  81.     WORD        ff;
  82.     WORD        np;
  83.     WORD        r1;
  84.     WORD        r2;
  85.     WORD        r3;
  86.     } MFDB;
  87.  
  88. /*------------------------------*/
  89. /*    Global            */
  90. /*------------------------------*/
  91. GLOBAL    WORD    gl_apid;
  92.  
  93. GLOBAL WORD    contrl[11];        /* control inputs        */
  94. GLOBAL WORD    intin[80];        /* max string length        */
  95. GLOBAL WORD    ptsin[256];        /* polygon fill points        */
  96. GLOBAL WORD    intout[45];        /* open workstation output    */
  97. GLOBAL WORD    ptsout[12];
  98.  
  99. GLOBAL    WORD    gl_wchar;        /* character width        */
  100. GLOBAL    WORD    gl_hchar;        /* character height        */
  101. GLOBAL    WORD    gl_wbox;        /* box (cell) width        */
  102. GLOBAL    WORD    gl_hbox;        /* box (cell) height        */
  103. GLOBAL    WORD    gem_handle;        /* GEM handle            */
  104. GLOBAL    WORD    vdi_handle;        /* VDI handle            */
  105. GLOBAL    WORD    work_out[57];        /* open virt workstation values    */
  106. GLOBAL    GRECT    scrn_area;        /* scrn area            */
  107. GLOBAL    MFDB    scrn_mfdb;        /* scrn memory def'n for blt    */
  108. GLOBAL    GRECT    full;            /* desktop size            */
  109. .bp
  110. /*------------------------------*/
  111. /*    External        */
  112. /*------------------------------*/
  113.  
  114. EXTERN    WORD    desel_obj();
  115.  
  116. /*------------------------------*/
  117. /*    Local            */
  118. /*------------------------------*/
  119.  
  120. MLOCAL    WORD    native_in = TRUE;    /* TRUE: input .RSC is native    */
  121.                     /* FALSE: input .RSC is foreign */
  122. MLOCAL    WORD    conv_def = TRUE;    /* TRUE: convert .DEF also    */
  123. MLOCAL    WORD    new_dfn = FALSE;    /* TRUE: use new symbol fmt    */
  124. MLOCAL    BYTE    old_rsc[4] = "RSC";    /* new resource file extent    */
  125. MLOCAL    BYTE    new_rsc[4] = "RS2";    /* new resource file extent    */
  126. MLOCAL    BYTE    old_def[4] = "DEF";    /* new definition file extend   */
  127. MLOCAL    BYTE    new_def[4] = "DF2";    /* new definition file extend   */
  128. MLOCAL    BYTE    r_file[81];        /* resource file name         */
  129. MLOCAL    BYTE    d_file[81];        /* definition file name     */
  130. MLOCAL    BYTE    r2_file[81];        /* output resource name        */
  131. MLOCAL    BYTE    d2_file[81];        /* output definition name    */
  132. MLOCAL    WORD    r_hndl = -1;        /* resource file handle     */
  133. MLOCAL    WORD    d_hndl = -1;        /* definition file handle     */
  134. MLOCAL    WORD    r2_hndl = -1;        /* output resource handle    */
  135. MLOCAL    WORD    d2_hndl = -1;        /* output definition handle    */
  136.  
  137. MLOCAL    LONG    f_err;            /* file error            */
  138. MLOCAL    BYTE    *head;            /* location of buffer        */
  139. MLOCAL    LONG    buff_size;        /* size of buffer        */
  140. MLOCAL    BYTE    buff[20];        /* def file work area        */
  141. MLOCAL    UWORD    img_offset, addr;    /* for image fixup        */
  142. MLOCAL    WORD    img_odd;        /* image fixup needed?        */
  143. MLOCAL    GRECT    prog_rect;        /* rectangle for prog indicator */
  144. .bp
  145. /*------------------------------*/
  146. /*    swap_bytes         */
  147. /*------------------------------*/
  148.     VOID
  149. swap_bytes(where, len)
  150.     BYTE    *where;
  151.     WORD    len;
  152.     {
  153.     BYTE    swap;
  154.  
  155.     for (; len > 0; len -= 2)
  156.         {
  157.         swap = *where;
  158.         *where = *(where + 1);
  159.         *(where + 1) = swap;
  160.         where += 2;
  161.         }
  162.     }
  163.  
  164. /*------------------------------*/
  165. /*    swap_words         */
  166. /*------------------------------*/
  167.     VOID
  168. swap_words(where, len)
  169.     WORD    *where;
  170.     WORD    len;
  171.     {
  172.     UWORD    swap;
  173.  
  174.     for (; len > 0; len -= 4)
  175.         {
  176.         swap = *where;
  177.         *where = *(where + 1);
  178.         *(where + 1) = swap;
  179.         where += 2;
  180.         }
  181.     }
  182. .bp
  183. /*------------------------------*/
  184. /*    swap_images         */
  185. /*------------------------------*/
  186.     VOID
  187. swap_images()
  188.     {
  189.     BITBLK    *where;
  190.     ICONBLK *where2;
  191.     BYTE    *taddr;
  192.     WORD    num;
  193.     WORD    wb, hl;
  194.  
  195.     where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
  196.     num = ((RSHDR *) head)->rsh_nbb;
  197.     for (; num--; where++)
  198.         {
  199.         taddr = where->bi_pdata;
  200.         wb = where->bi_wb;
  201.         hl = where->bi_hl;
  202.         if ((LONG) taddr != -1L)
  203.             {
  204.             if (img_odd)
  205.                 where->bi_pdata = ++taddr;
  206.             swap_bytes(head + taddr, wb * hl);
  207.             }
  208.         }
  209.  
  210.     where2 = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
  211.     num = ((RSHDR *) head)->rsh_nib;
  212.     for (; num--; where2++)
  213.         {
  214.         wb = (where2->ib_wicon + 7) >> 3;
  215.         hl = where2->ib_hicon;
  216.         taddr = where2->ib_pdata;
  217.         if ((LONG) taddr != -1L)
  218.             {
  219.             if (img_odd)
  220.                 where2->ib_pdata = ++taddr;
  221.             swap_bytes(head + taddr, wb * hl);
  222.             }
  223.         taddr = where2->ib_pmask;
  224.         if ((LONG) taddr != -1L)
  225.             {
  226.             if (img_odd)
  227.                 where2->ib_pmask = ++taddr;
  228.             swap_bytes(head + taddr, wb * hl);
  229.             }
  230.         }
  231.     }
  232. .bp
  233. /*------------------------------*/
  234. /*    swap_trees         */
  235. /*------------------------------*/
  236.     VOID
  237. swap_trees()
  238.     {
  239.     BYTE    *where;
  240.     WORD    size;
  241.  
  242.     where = head + ((RSHDR *) head)->rsh_trindex;
  243.     size = ((RSHDR *) head)->rsh_ntree * sizeof(LONG);
  244.     swap_bytes(where, size);
  245.     swap_words((WORD *) where, size);
  246.     }
  247.  
  248. /*------------------------------*/
  249. /*    swap_objs         */
  250. /*------------------------------*/
  251.     VOID
  252. swap_objs()
  253.     {
  254.     OBJECT    *where;
  255.     WORD    num;
  256.  
  257.     where = (OBJECT *) (head + ((RSHDR *) head)->rsh_object);
  258.     num = ((RSHDR *) head)->rsh_nobs;
  259.     swap_bytes((BYTE *) where, num * sizeof(OBJECT));
  260.     for (; num--; where++)
  261.         swap_words((WORD *) &where->ob_spec, sizeof(LONG));
  262.     }
  263. .bp
  264. /*------------------------------*/
  265. /*    swap_teds         */
  266. /*------------------------------*/
  267.     VOID
  268. swap_teds()
  269.     {
  270.     TEDINFO    *where;
  271.     WORD    num;
  272.  
  273.     where = (TEDINFO *) (head + ((RSHDR *) head)->rsh_tedinfo);
  274.     num = ((RSHDR *) head)->rsh_nted;
  275.     swap_bytes((BYTE *) where, num * sizeof(TEDINFO));
  276.     for (; num--; where++)
  277.         {
  278.         swap_words((WORD *) &where->te_ptext, sizeof(LONG));
  279.         swap_words((WORD *) &where->te_ptmplt, sizeof(LONG));
  280.         swap_words((WORD *) &where->te_pvalid, sizeof(LONG));
  281.         }
  282.     }
  283.  
  284. /*------------------------------*/
  285. /*    swap_ibs         */
  286. /*------------------------------*/
  287.     VOID
  288. swap_ibs()
  289.     {
  290.     ICONBLK    *where;
  291.     WORD    num;
  292.  
  293.     where = (ICONBLK *) (head + ((RSHDR *) head)->rsh_iconblk);
  294.     num = ((RSHDR *) head)->rsh_nib;
  295.     swap_bytes((BYTE *) where, num * sizeof(ICONBLK));
  296.     for (; num--; where++)
  297.         {
  298.         swap_words((WORD *) &where->ib_pdata, sizeof(LONG));
  299.         swap_words((WORD *) &where->ib_pmask, sizeof(LONG));
  300.         swap_words((WORD *) &where->ib_ptext, sizeof(LONG));
  301.         }
  302.     }
  303. .bp
  304. /*------------------------------*/
  305. /*    swap_bbs         */
  306. /*------------------------------*/
  307.     VOID
  308. swap_bbs()
  309.     {
  310.     BITBLK    *where;
  311.     WORD    num;
  312.  
  313.     where = (BITBLK *) (head + ((RSHDR *) head)->rsh_bitblk);
  314.     num = ((RSHDR *) head)->rsh_nbb;
  315.     swap_bytes((BYTE *) where, num * sizeof(BITBLK));
  316.     for (; num--; where++)